package interfaces.subpanel.cargardatos.gui;

import javax.swing.AbstractListModel;
import javax.swing.ComboBoxModel;

import enumerations.AttributesEnum;

public class MyComboBoxModel extends AbstractListModel implements ComboBoxModel {

	private static final long serialVersionUID = 1L;

	AttributesEnum[] attributes = AttributesEnum.values();

	AttributesEnum selection = null;

	public Object getElementAt(int index) {
		return attributes[index];
	}

	public int getSize() {
		return attributes.length;
	}

	/**
	 * To select and register an item from the pull-down list.
	 */
	public void setSelectedItem(Object anItem) {
		selection = (AttributesEnum) anItem;
	}

	/**
	 * Methods implemented from the interface ComboBoxModel to add the selection to the combo box.
	 */
	public Object getSelectedItem() {
		return selection;
	}

}
